﻿using Prism.Commands;
using System.Diagnostics;
using System.Text;
using System.Windows;

namespace Loaf.ViewModels
{
    public class HomeViewModel
    {
        public HomeViewModel()
        {
            Version = "当前版本：" + Application.ResourceAssembly.GetName().Version.ToString() + "\n";


            StringBuilder readme = new StringBuilder();
            readme.AppendLine("1.书架页面：查看书架、搜索书籍");
            readme.AppendLine("2.设置页面：设置快捷键");
            Readme = readme.ToString();

            StringBuilder tips = new StringBuilder();
            tips.AppendLine("1.搜索功能，回车进行搜索");
            tips.AppendLine("2.阅读模式直接关闭，再使用快捷键打开程序可回到主页面");
            Tips = tips.ToString();






            WebCommand = new DelegateCommand<string>(WebAction);
        }

        /// <summary>
        /// 版本号
        /// </summary>
        public string Version { get; set; }
        /// <summary>
        /// 使用说明
        /// </summary>
        public string Readme { get; set; }
        /// <summary>
        /// 操作说明
        /// </summary>
        public string Tips { get; set; }

        public DelegateCommand<string> WebCommand { get; set; }

        /// <summary>
        /// 打开网页
        /// </summary>
        /// <param name="web"></param>
        public void WebAction(string web)
        {
            try
            {
                var psi = new ProcessStartInfo
                {
                    FileName = web,
                    UseShellExecute = true
                };
                Process.Start(psi);
            }
            catch
            {

            }
        }
    }
}
